{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a9b2bb0e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0b101\n"
     ]
    }
   ],
   "source": [
    "x = 5\n",
    "x_bin = bin(x)\n",
    "print(x_bin)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d2c2ebf2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "0\n",
      "b\n",
      "1\n",
      "0\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "print(len(x_bin))\n",
    "for s in x_bin:\n",
    "    print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "fd4a9dff",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2, 4]\n"
     ]
    }
   ],
   "source": [
    "index = []\n",
    "for i in range(2, len(x_bin)):\n",
    "    if x_bin[i] == '1':\n",
    "        index.append(i)\n",
    "print(index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "8db3cdc9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2]\n"
     ]
    }
   ],
   "source": [
    "if len(index) == 1 or len(index) == 0:\n",
    "    print(0)\n",
    "else:\n",
    "    distance = []\n",
    "    for j in range(1, len(index)):\n",
    "        distance.append(index[j]-index[j-1])\n",
    "    print(distance)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "99ace85c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "max(index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f7e971d5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
